<?php 
/**
*	信呼文档编辑平台
*	登录页
*/
class loginClassAction extends ActionNot
{
	
	public function defaultAction()
	{
		if(!getconfig('def_pass'))return '欢迎您的使用，请从<a href="http://www.rockoa.com/user.html">信呼官网</a>上登录';
	}
	
	public function exitAction()
	{
		$this->rock->clearsession('adminid');
		$this->rock->location('?m=login');
	}
	
	public function logincheckAction()
	{
		$user = addslashes($this->post('user'));
		$pass = addslashes($this->post('pass'));
		if(isempt($user))return '账号不能为空';
		if(isempt($pass))return '密码不能为空';
		$files = 'user';
		if(c('check')->isemail($user))$files='email';
		if(c('check')->ismobile($user))$files='mobile';
		
		$urs  = m('users')->getone("`$files`='$user'");
		if(!$urs)return '账号密码错误';
		if(!isempt($urs['rand']))$pass .= $urs['rand'];
		if($urs['pass']!=md5($pass))return '账号密码错误';
		
		$this->rock->savesession(array(
			'adminid'	=> $urs['id'],
		));
		
		return 'ok';
	}
}